Skip to content

feat: Local database mode with PostgreSQL + PostgREST (no Supabase cloud required)#948

Closed
LEEI1337 wants to merge 2 commits intocoleam00:stablefrom
LEEI1337:feature/local-database
Closed

feat: Local database mode with PostgreSQL + PostgREST (no Supabase cloud required)#948
LEEI1337 wants to merge 2 commits intocoleam00:stablefrom
LEEI1337:feature/local-database

Conversation

@LEEI1337
Copy link
Copy Markdown

@LEEI1337 LEEI1337 commented Apr 3, 2026

Summary

  • Add LOCAL_DB=true option to run Archon entirely locally with no Supabase cloud dependency — all data stays on the user's machine
  • Add 3 new Docker services: PostgreSQL 16 + pgvector, PostgREST, and an Nginx proxy for Supabase URL compatibility
  • Zero Python code refactoring needed — the supabase-py client works identically in both modes
  • Fully backward compatible — existing Supabase cloud users are unaffected

Architecture

PostgreSQL 16 + pgvector → PostgREST → Nginx Proxy (/rest/v1/ → /) → supabase-py

The Nginx proxy maps /rest/v1/ paths to PostgREST's root paths, making it fully compatible with the supabase-py client.

What's Changed

New files

  • local-db/nginx.conf — Nginx proxy for Supabase URL compatibility
  • local-db/complete_setup_local.sql — Complete DB schema with RLS policies adapted for PostgREST (no auth.role())

Modified files

  • docker-compose.yml — Add archon-db, archon-postgrest, archon-postgrest-proxy services (profile: local-db)
  • .env.example — Add LOCAL_DB toggle and local database configuration
  • python/src/server/config/config.py — Skip JWT validation in local mode, auto-configure URLs
  • python/src/server/services/client_manager.py — Local database URL handling
  • python/src/server/services/credential_service.py — Local database URL handling
  • Makefile — Add dev-local-db, local-db-up/down/reset/logs commands
  • README.md — Document local database mode with architecture diagrams

Usage

# In .env:
LOCAL_DB=true

# Then start:
make dev-local-db
# or:
docker compose --profile full --profile local-db up -d

No Supabase account needed. No manual SQL execution. Everything starts automatically.

Why This Approach

There have been several attempts at database abstraction (#918, #915, #375) involving heavy Python refactoring. This approach avoids all that by using PostgREST as a drop-in replacement for the Supabase REST API, keeping the existing supabase-py client calls 100% intact.

Add LOCAL_DB=true option to run Archon entirely locally without
Supabase cloud dependency. All data stays on the user's machine.

Changes:
- docker-compose.yml: Add archon-db (pgvector/pgvector:pg16),
  archon-postgrest, and archon-postgrest-proxy (nginx) services
- local-db/: New directory with nginx.conf (Supabase URL compatibility
  layer) and complete_setup_local.sql (RLS policies adapted for
  PostgREST without Supabase Auth)
- .env.example: Add LOCAL_DB toggle and local database configuration
- config.py: Skip JWT validation in local mode, auto-configure URLs
- client_manager.py: Auto-configure Supabase client for local PostgREST
- credential_service.py: Same local database support
- Makefile: Add dev-local-db, local-db-up/down/reset/logs commands
- README.md: Document local database mode with architecture diagrams

Architecture: PostgreSQL 16 + pgvector → PostgREST → Nginx proxy
(/rest/v1/ → /) for full supabase-py compatibility without code changes.
- Remove head=True from all count queries to fix postgrest-py bug
  where Content-Range headers with '*' caused int() crash
- Fix validate_supabase_url to allow Docker service names in local mode
- Fix internal port references for PostgREST proxy
- Add JWT secret for PostgREST authentication
- Fix missing return statement in _get_encryption_key
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 3, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 01716b8b-c597-4e6c-9134-f0ef9f2e59ca

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@LEEI1337 LEEI1337 closed this Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants